import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LogisticsCompanyVO, LogisticsCompanyForm, LogisticsCompanyQuery } from '@/api/order/logisticsCompany/types';

/**
 * 查询物流提醒设置列表
 * @param query
 * @returns {*}
 */

export const listLogisticsCompany = (query?: LogisticsCompanyQuery): AxiosPromise<LogisticsCompanyVO[]> => {
    return request({
        url: '/order/logisticsCompany/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询物流提醒设置详细
 * @param id
 */
export const getLogisticsCompany = (id: string | number): AxiosPromise<LogisticsCompanyVO> => {
    return request({
        url: '/order/logisticsCompany/' + id,
        method: 'get'
    });
};

/**
 * 新增物流提醒设置
 * @param data
 */
export const addLogisticsCompany = (data: LogisticsCompanyForm) => {
    return request({
        url: '/order/logisticsCompany',
        method: 'post',
        data: data
    });
};

/**
 * 修改物流提醒设置
 * @param data
 */
export const updateLogisticsCompany = (data: LogisticsCompanyForm) => {
    return request({
        url: '/order/logisticsCompany',
        method: 'put',
        data: data
    });
};
/**
 * 获取所有快递公司
 * @param data
 */
export const getCourierCompany = () => {
    return request({
        url: '/order/courierCompany/allList',
        method: 'get',
    });
};

/**
 * 删除物流提醒设置
 * @param id
 */
export const delLogisticsCompany = (id: string | number | Array<string | number>) => {
    return request({
        url: '/order/logisticsCompany/' + id,
        method: 'delete'
    });
};

export default {
    list: listLogisticsCompany,
    get: getLogisticsCompany,
    add: addLogisticsCompany,
    update: updateLogisticsCompany,
    del: delLogisticsCompany,
}